﻿'So this code makes changes to the visual layout of the main form (form1). Code for changeing the background is actually in
'form1.vb, but it is called from here. 

Imports System.IO
Public Class theme
    Dim bset As Boolean = False
    Dim bsettings As Boolean = False
    Private Sub theme_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Button8.Hide()

        If My.Settings.customthemeYN = 1 Then
            loadBlinks()
        End If

        If My.Settings.theme = 0 Then
            RadioButton2.PerformClick()
        Else
            RadioButton1.PerformClick()
        End If

        If My.Settings.notify = 0 Then

        End If
        If My.Settings.notify = 1 Then
            cbnotify1.Checked = True
        End If
        If My.Settings.notify = 2 Then
            cbnotify2.Checked = True
        End If
        If My.Settings.notify = 3 Then
            cbnotify1.Checked = True
            cbnotify2.Checked = True
        End If
    End Sub

    Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click 'Button8 = save button.
        Dim resetBack As Boolean = False
        If bset = False Then
            If MessageBox.Show("Would you like to use this theme's default background?", "Ultra Super Important Question", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
                resetBack = True
            Else
                resetBack = False
            End If
        End If
        If RadioButton1.Checked = True Then
            My.Settings.theme = 1
            My.Settings.Save()
            If resetBack = True Then
                KHM.Main.BackgroundImage.Dispose()
                KHM.Main.BackgroundImage = My.Resources.drsshm79
                KHM.Main.BackgroundImageLayout = ImageLayout.Stretch
                File.Delete("background.jpg")
            Else
            End If
        End If
        If RadioButton2.Checked = True Then
            My.Settings.theme = 0
            My.Settings.Save()
            If resetBack = True Then
                KHM.Main.BackgroundImage.Dispose()
                KHM.Main.BackgroundImage = My.Resources.drsshm6
                KHM.Main.BackgroundImageLayout = ImageLayout.Center
                File.Delete("background.jpg")
            Else
            End If
        End If

        Dim notify012 As Integer
        notify012 = 0
        If cbnotify1.Checked = True Then
            notify012 = notify012 + 1
        End If
        If cbnotify2.Checked = True Then
            notify012 = notify012 + 2
        End If
        My.Settings.notify = notify012

        My.Settings.Save()
        KHM.Main.themestart()
        If bsettings = True Then
            setBlinks()
        End If
        Me.Close()
    End Sub
    Private Sub loadBlinks()
        Dim blinks(10) As String
        blinks(10) = KHM.Main.linkButtons(4242)

        drssbtext.Text = My.Settings.blinks0
        pbbtext.Text = My.Settings.blinks1
        pilotbtext.Text = My.Settings.blinks2
        emailbtext.Text = My.Settings.blinks3
        megabtext.Text = My.Settings.blinks4
        drssbweb.Text = My.Settings.blinks5
        pbbweb.Text = My.Settings.blinks6
        pilotbweb.Text = My.Settings.blinks7
        emailbweb.Text = My.Settings.blinks8
        megabweb.Text = My.Settings.blinks9
        header1text.Text = My.Settings.blinks10
    End Sub
    Private Sub setBlinks()  'b-links
        Dim blinks(10) As String
        Dim i As Integer = 0

        blinks(0) = drssbtext.Text
        blinks(1) = pbbtext.Text
        blinks(2) = pilotbtext.Text
        blinks(3) = emailbtext.Text
        blinks(4) = megabtext.Text
        blinks(5) = drssbweb.Text
        blinks(6) = pbbweb.Text
        blinks(7) = pilotbweb.Text
        blinks(8) = emailbweb.Text
        blinks(9) = megabweb.Text
        blinks(10) = header1text.text

        While i <= 10
            If blinks(i) = "" Then
                If i = 0 Then
                    blinks(0) = "Dayton STEM School"
                End If
                If i = 1 Then
                    blinks(1) = "Open Progress Book"
                End If
                If i = 2 Then
                    blinks(2) = "Open Pilot"
                End If
                If i = 3 Then
                    blinks(3) = "Open Email"
                End If
                If i = 4 Then
                    blinks(4) = "Open MEGA"
                End If
                If i = 5 Then
                    blinks(5) = "http://daytonstemschool.org"
                End If
                If i = 6 Then
                    blinks(6) = "https://gb.mdeca.org/ParentAccess/"
                End If
                If i = 7 Then
                    blinks(7) = "https://pilot.wright.edu"
                End If
                If i = 8 Then
                    blinks(8) = "https://wings.wright.edu"
                End If
                If i = 9 Then
                    blinks(9) = "https://mega.co.nz"
                End If
                If i = 10 Then
                    blinks(10) = "DRSS Homework Manager | "
                End If
            End If
            i = i + 1
        End While
        My.Settings.blinks0 = blinks(0)
        My.Settings.blinks1 = blinks(1)
        My.Settings.blinks2 = blinks(2)
        My.Settings.blinks3 = blinks(3)
        My.Settings.blinks4 = blinks(4)
        My.Settings.blinks5 = blinks(5)
        My.Settings.blinks6 = blinks(6)
        My.Settings.blinks7 = blinks(7)
        My.Settings.blinks8 = blinks(8)
        My.Settings.blinks9 = blinks(9)
        My.Settings.blinks10 = blinks(10)
        My.Settings.customthemeYN = 1
        My.Settings.Save()
        MsgBox("Your settings have been saved. Please restart drsshm to apply.")
    End Sub
    Public Sub backgroundWasSet(bwset As Boolean) ' "Was the background just set, form1?"
        If bwset = True Then
            bset = True
        Else
            bset = False
        End If
    End Sub
    Private Sub Button1_Click_2(sender As Object, e As EventArgs) Handles Button1.Click
        KHM.Main.setBack()
    End Sub

   
    Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
        Button8.Show()
    End Sub

    Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged
        Button8.Show()
    End Sub

    Private Sub drssbtext_TextChanged(sender As Object, e As EventArgs) Handles drssbtext.TextChanged
        bsettings = True
        drssb.Text = drssbtext.Text
    End Sub

    Private Sub pbbtext_TextChanged(sender As Object, e As EventArgs) Handles pbbtext.TextChanged
        bsettings = True
        pbb.Text = pbbtext.Text
    End Sub

    Private Sub pilotbtext_TextChanged(sender As Object, e As EventArgs) Handles pilotbtext.TextChanged
        bsettings = True
        pilotb.Text = pilotbtext.Text
    End Sub

    Private Sub emailbtext_TextChanged(sender As Object, e As EventArgs) Handles emailbtext.TextChanged
        bsettings = True
        emailb.Text = emailbtext.Text
    End Sub

    Private Sub megabtext_TextChanged(sender As Object, e As EventArgs) Handles megabtext.TextChanged
        bsettings = True
        megab.Text = megabtext.Text
    End Sub

    Private Sub Panel2_Paint(sender As Object, e As PaintEventArgs) Handles Panel2.Paint

    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles header1text.TextChanged
        bsettings = True
        header1label.Text = header1text.Text
    End Sub

    
    Private Sub Button4_Click(sender As Object, e As EventArgs)

    End Sub
End Class
'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.

'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>